package com.sfc.sdsr.server.commands;

import com.sfc.sdsr.common.model.Song;
import com.sfc.sdsr.server.ClientData;
import com.sfc.sdsr.server.dao.DaoFactory;

public class CreateSong extends Command {

	private Song newSong;
	
	public CreateSong(ClientData clientData) {
		dao = DaoFactory.getDao();
		if (clientData.getOperationParameter() instanceof Song) {
			newSong = (Song) clientData.getOperationParameter();
		} else {
			log.error("Can't create new song. Client Data corrupted, no Song found to Create");
			shouldExecute = false;
			returnObject = null;
		}
	}

	@Override
	public void execute() {
		log.info("Creating Song");
	    returnObject = dao.createSong(newSong);
	}

}
